package com.xjtu.platform.user.assister.consultChange.dao;

import com.xjtu.platform.user.assister.consultChange.*;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface ConsultChangeDao {
    @Select("select count_num as count,student_id,consult.visit_id,visiter_id,day,place_name,time.start_time,time.end_time from consult,first_visit,duty,time where consult.visit_id=first_visit.visit_id and consult.duty_id=duty.duty_id and (consult.state=1 or consult.state=2) and duty.time_id=time.time_id and consult.visit_id in (select visit_id from first_visit where student_id like #{student_id})")
    List<ConsultRecordModel> getConsultRecord(ConsultChangeDto consultChangeDto);

    @Select("select time_id from duty where place_name=#{place_name} and day=#{day}")
    List<FreeTimeModel> getFreeTime(FreeTimeDto freeTimeDto);

    @Select("select time_id,start_time,end_time from time where time_id=#{time_id}")
    FreeTimeModel getTimeInfo(String time_id);

    @Update("update duty set time_id=#{time_id},day=#{day},place_name=#{place_name} where duty_id in (select duty_id from consult where visit_id=#{visit_id} and count_num=#{count}) ")
    void insertTimeInfo(InsertTimeDto insertTimeDto);
}
